﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="addrbook_personal_edit.aspx.cs" Inherits="Ccit.OA.AddrBook.addrbook_personal_edit" %>
<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>个人通讯录编辑</title>
      <script language="javascript" type="text/javascript" src="../script/jquery.js"></script>
    <script language="javascript" type="text/javascript" src="../script/StringClass_Ext.js"></script>
    <script language="javascript" type="text/javascript" src="../script/jsonlib.js"></script>
    <script language="javascript" src="../script/jwindow.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jcontrol.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jbase64.js" type="text/javascript"></script>
    <script type="text/javascript">
        function CheckForm()
        {
            var vName = document.getElementById("txtName").value;
            if(vName.Trim()=="")
            {
                alert("名称不能为空!");
                document.getElementById("txtName").focus();        
                return false;
            }
             var vbirthDate = document.getElementById("txtBirthDay").value;
                if(vbirthDate.Trim()!="")
                {
                    if(!vbirthDate.IsDate())
                    {
                        alert("生日格式不正确!");
                        document.getElementById("txtBirthDay").focus();                      
                        return false;
                    }
                } 
            var email = document.getElementById("txtEmail").value;
            if(email.Trim()!="")
            {
                if(!email.IsEmail())
                {
                    alert("邮箱格式不正确!");
                    document.getElementById("txtEmail").focus();                      
                    return false;
                }
            }
            var pcode = document.getElementById("txtPostCode").value;
            if(pcode.Trim()!="")
            {
                if(!pcode.IsPostCode())
                {
                    alert("邮政编码格式不正确!");
                    document.getElementById("txtPostCode").focus();                      
                    return false;
                }
            }
            return true;
        }        
        function doSave(oType)
        {
            if(CheckForm()==true)
            {
                var msAddBook = {}; //消息对象
                msAddBook.ID = document.getElementById("_hidsRecId").value;
                msAddBook.Name = document.getElementById("txtName").value;
                msAddBook.Call = document.getElementById("txtCall").value;
                msAddBook.Birthday = document.getElementById("txtBirthDay").value;
                msAddBook.GroupId = document.getElementById("ddlGroup").value;
                msAddBook.Company = document.getElementById("txtCompany").value;
                msAddBook.DeptName = document.getElementById("txtDeptName").value;
                msAddBook.PostName = document.getElementById("txtPostName").value;
                msAddBook.Telphone = document.getElementById("txtTelphone").value; 
                msAddBook.Comtel = document.getElementById("txtComTel").value;
                msAddBook.Fax = document.getElementById("txtFax").value;
                msAddBook.Ftel = document.getElementById("txtFtel").value;
                msAddBook.makenum = document.getElementById("ddlMakeNum").value;
                msAddBook.Maddress = document.getElementById("txtMaddress").value;
                msAddBook.Postcode = document.getElementById("txtPostCode").value; 
                msAddBook.email = document.getElementById("txtEmail").value;
                msAddBook.msnname = document.getElementById("txtMsnName").value;
                msAddBook.qname = document.getElementById("txtQName").value;
                msAddBook.url = document.getElementById("txtUrl").value;
                msAddBook.remark = document.getElementById("txtRemark").value;
                var jsonExpr = JSON.stringify(msAddBook,function(key,value){return value;}); 
                      msAddBook = null; 
                PageMethods.DoSaveMes(jsonExpr,oType,ClientCallBack);     
            }            
        }
         function ClientCallBack(vResult)
          {
                eval("resultObj ="+vResult)
                if(resultObj.result!="-999")
                {
                    alert(resultObj.message);
                    switch(resultObj.ctrtype){
                         case "1":
                            $get("_hidsRecId").value = resultObj.result;
                            break;
                         case "2": 
                            doClear();
                            break;
                         case "3":
                            doBack();
                            break;
                         case "4":                            
                            break;
                    }
                }
                else
                {
                    alert(resultObj.message)
                }
                resultObj = null;
          }
          function doBack()
          { 
                var strURL = "addrbook_personal_index.aspx";
                document.location.href = strURL;
          }
          function doClear()
          {
             document.getElementById("_hidsRecId").value = "";
             document.getElementById("txtName").value="";
             document.getElementById("txtCall").value="";
             document.getElementById("txtBirthDay").value="";                 
             document.getElementById("txtCompany").value="";
             document.getElementById("txtDeptName").value="";
             document.getElementById("txtPostName").value="";
             document.getElementById("txtTelphone").value=""; 
             document.getElementById("txtComTel").value="";
             document.getElementById("txtFax").value="";
             document.getElementById("txtFtel").value="";                 
             document.getElementById("txtMaddress").value="";
             document.getElementById("txtPostCode").value=""; 
             document.getElementById("txtEmail").value="";
             document.getElementById("txtMsnName").value="";
             document.getElementById("txtQName").value ="";
             document.getElementById("txtUrl").value ="";
             document.getElementById("txtRemark").value ="";  
          }
    </script>
</head>
<body>
    <ccit:ActionForm id="form1" runat="server">
    <input type="hidden" id="_hidsRecId" runat="server" />
     <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager> 
    <table class="tbToolbar" cellpadding="0" cellspacing="0" width="98%" align="center">
            <tr>
            <td width="2%" align="left">
                <div class="tbSeparator">
                </div>
            </td>
            <td class="titlebar" width="38%">                   
                 个人通讯录编辑
            </td>
            <td align="right">               				 
					<nobr></nobr>            
            </td>
            <td align="right">
                <nobr>
            </td>            
          </tr>
         </table>
         <table cellpadding="0" class="tableborder" cellspacing="0" width="98%" align="center" id="tdMessage" runat="server">
           <tr>
            <td align="right" width="10%" class="pformleft">名称</td>
            <td width="20%" class="pformrightline">
                <asp:TextBox  ID="txtName" Runat="server" CssClass="input" Width="98%" MaxLength="40"></asp:TextBox>
            </td>
            <td  align="right" width="8%" class="pformleft">称谓</td>
            <td width="15%" class="pformrightline">
                <asp:TextBox  ID="txtCall" Runat="server" CssClass="input" Width="98%" MaxLength="18"></asp:TextBox>
            </td>
            <td align="right" width="10%" class="pformleft">生日</td>
            <td width="15%" class="pformrightline">
            <nobr>
                <asp:TextBox  ID="txtBirthDay" Runat="server" CssClass="input" Width="70%" MaxLength="18"></asp:TextBox>
                 <img class="getdate" src="../images/toolbar/Calendar.gif"  relaobj="txtBirthDay"/>
            </nobr>
            </td>
            <td align="right" width="8%" class="pformleft">分组</td>
            <td width="20%" class="pformright">
                 <asp:DropDownList  ID="ddlGroup" Runat="server" CssClass="inputselect" Width="98%"></asp:DropDownList>   
            </td>
          </tr>
          <tr>
            <td align="right" class="pformleft">单位</td>
            <td colspan="3" class="pformrightline">
                <asp:TextBox  ID="txtCompany" Runat="server" CssClass="input" Width="98%" MaxLength="90"></asp:TextBox>
            </td>
            <td align="right" class="pformleft">部门</td>
            <td class="pformrightline">
                <asp:TextBox  ID="txtDeptName" Runat="server" CssClass="input" Width="98%" MaxLength="40"></asp:TextBox>
            </td>
            <td align="right" class="pformleft">职务</td>
            <td class="pformright">
                <asp:TextBox  ID="txtPostName" Runat="server" CssClass="input" Width="98%" MaxLength="40"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td align="right" class="pformleft">手机</td>
            <td colspan="3" class="pformrightline">
                <asp:TextBox  ID="txtTelphone" Runat="server" CssClass="input" Width="98%" MaxLength="40"></asp:TextBox>
            </td>
            <td align="right" class="pformleft">办公电话</td>
            <td colspan="3" class="pformright">
                <asp:TextBox  ID="txtComTel" Runat="server" CssClass="input" Width="98%" MaxLength="40"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td align="right" class="pformleft">传真</td>
            <td colspan="3" class="pformrightline">
                <asp:TextBox  ID="txtFax" Runat="server" CssClass="input" Width="98%" MaxLength="40"></asp:TextBox>
            </td>
            <td align="right" class="pformleft">家庭电话</td>
            <td class="pformrightline">
                <asp:TextBox  ID="txtFtel" Runat="server" CssClass="input" Width="98%" MaxLength="40"></asp:TextBox>
            </td>
            <td align="right" class="pformleft">标志</td>
            <td class="pformright">
                <asp:DropDownList  ID="ddlMakeNum" Runat="server" CssClass="inputselect" Width="98%"></asp:DropDownList>
             </td>
          </tr>
          <tr>
            <td align="right" class="pformleft">邮寄地址</td>
            <td colspan="5" class="pformrightline">
                <asp:TextBox  ID="txtMaddress" Runat="server" CssClass="input" Width="98%" MaxLength="90"></asp:TextBox>
            </td>
            <td align="right" class="pformleft">邮编</td>
            <td class="pformright">
                <asp:TextBox  ID="txtPostCode" Runat="server" CssClass="input" Width="98%" MaxLength="6"> </asp:TextBox>
            </td>
          </tr>
          <tr>
            <td align="right" class="pformleft">电子邮件</td>
            <td colspan="3" class="pformrightline">
                <asp:TextBox  ID="txtEmail" Runat="server" CssClass="input" Width="98%" MaxLength="40"></asp:TextBox>
            </td>
            <td align="right" class="pformleft">MSN</td>
            <td colspan="3" class="pformright">
                <asp:TextBox  ID="txtMsnName" Runat="server" CssClass="input" Width="98%" MaxLength="40"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td align="right" class="pformleft">QQ</td>
            <td colspan="3" class="pformrightline">
                <asp:TextBox  ID="txtQName" Runat="server" CssClass="input" Width="98%" MaxLength="40"></asp:TextBox>
            </td>
            <td align="right" class="pformleft">网址</td>
            <td colspan="3" class="pformright">
                <asp:TextBox  ID="txtUrl" Runat="server" CssClass="input" Width="98%" MaxLength="250"></asp:TextBox>
            </td>
          </tr>
          <tr>
            <td align="right" class="pformleft">备注</td>
            <td colspan="7" class="pformright">
                <asp:TextBox  ID="txtRemark" Runat="server" CssClass="input" Width="98%" Height="80" TextMode="MultiLine" MaxLength="490"></asp:TextBox>
            </td>
          </tr>
        <tr class="pformstrip" height="20">
           <td colspan="8" align="center">
                <input type="button" id="btnSave" value="保存" class="button" onclick="doSave('1')" />
                &nbsp;
                <input type="button" id="btnSaveCont" value="保存并新增" class="button" onclick="doSave('2')" />
                &nbsp;
                <input type="button" id="btnSaveBack" value="保存并返回" class="button" onclick="doSave('3')" />
                &nbsp;  
                <input type="button" id="btnBack" value="返回" class="button" onclick="doBack()" />
                &nbsp;
            </td>
        </tr>
      </table> 
    </ccit:ActionForm>
</body>
</html>
